<template>
  <div class="video-player">
    <template>
      <div v-if="mode === 'edit'">
        <video
          class="video-container"
          :src="source"
          :autoplay="autoplay"
          :loop="loop"
          :muted="muted"
          :controls="disabled? false : true"
          style="width:320;height:240"
        ></video>
      </div>
      <div v-else>{{ value }}</div>
    </template>
  </div>
</template>

<script>
export default {
  name: "video",
  components: {},
  props: {
    value: {},
    mode: {
      default: "edit", // 编辑模式和 edit， 展示模式 view
    },
    readonly: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    source: {
      type: String,
      default: "",
    },
    autoplay: {
      type: Boolean,
      default: false,
    },
    loop: {
      type: Boolean,
      default: false,
    },
    muted: {
      type: Boolean,
      default: false,
    },
    // controls: {
    //   type: Boolean,
    //   default: false,
    width: {
      type: Number,
      default: 320,
    },
    height: {
      type: Number,
      default: 240,
    },
  },
  data() {
    return {

    };
  },
  computed: {},
  watch: {},
  created() {
  },
  mounted() {
    if (this.value) {
      this.source = this.value;
      if (this.mode == "view") {
        this.disabled = true;
      }
    }
  },
  methods: {
  },
};
</script>
<style lang="scss" scoped>
.video-player {
  width: 100%;
}

.video-container {
  object-fit: fill;
}
</style>
